<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:inline="javascript">
        $(function () {
            $.getJSON("/roles",function (date) {
                $("[name=bmid]").append("<option value='0'>请选择</option>");
                let roleId = [[${user.bmid}]]
                for (let relo of date){
                    if(relo.id == roleId){
                        $("[name=bmid]").append("<option selected value='"+relo.id+"'>"+relo.bmname+"</option>");
                    }else {
                        $("[name=bmid]").append("<option value='"+relo.id+"'>"+relo.bmname+"</option>");
                    }
                }
            })
        })
    </script>
</head>
<body>
<form th:action="@{/users/update}" method="post">
    <input type="hidden" name="id" th:value="${user.id}">
    <table>
        <tr>
            <td>account</td>
            <td><input name="account" th:value="${user.account}"></td>
        </tr>
        <tr>
            <td>realname</td>
            <td><input name="realname" th:value="${user.realname}"></td>
        </tr>
        <tr>
            <td>birthday</td>
            <td><input name="birthday" th:value="${#dates.format(user.birthday,'yyyy-MM-dd')}"></td>
        </tr>
        <tr>
            <td>bmid</td>
            <td><select name="bmid">
            </select></td>
        </tr>
        <tr>
            <td>sex</td>
            <td><input name="sex" th:value="${user.sex}"></td>
        </tr>
        <tr>
            <td><input type="submit" value="修改"></td>
        </tr>
    </table>
</form>
</body>
</html>